<!doctype html>
<html lang="en" class="fixed">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>增加课次</title>
    <link rel="apple-touch-icon" sizes="120x120" href="favicon/apple-icon-120x120.png">
    <link rel="icon" type="image/png" sizes="192x192" href="favicon/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/layui/css/layui.css')) ?>" media="all">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/animate.css/animate.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/font-awesome/css/font-awesome.css')) ?>">
    <link rel="stylesheet"
          href="<?php xcho(loadSource('/assets/plugins/data-table/media/css/dataTables.bootstrap.min.css')) ?>">
    <!--    <link rel="stylesheet" href="-->
    <?php //xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?><!--">-->
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/metroStyle/metroStyle.css')) ?>"
          type="text/css">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/style.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/app.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/css/new_main.css')) ?>">
    
    <style>
        * {
            margin:: 0;
            padding: 0;
            box-sizing: border-box;
        }

        ul, li, ol, li {
            list-style: none;
        }

        body {
            background: #f4f4f4;
        }

        .sort-content {
            width: 900px;
            margin: 0 auto;
            background: #fff;
        }

        .sort-content .sort-title {
            padding: 20px;
            border-bottom: 1px #ccc solid;
        }

        .sort-content .sort-cont {
            padding: 20px;
        }

        .sort-content .sort-cont {
            margin-top: 10px;
        }

        .sort-content .sort-cont .classTime-student ul {
            border-bottom: 1px #eee solid;
            padding-bottom: 10px;
        }

        .sort-content .sort-cont .classTime-student ul li {
            display: inline-block;
            text-align: center;
            font-size: 12px;
            cursor: pointer;
            margin: 0 10px;
        }

        .sort-content .sort-cont .classTime-student ul li span {
            color: #108EE9;
        }

        .sort-content .sort-cont .order ul li.active {
            border-bottom: 2px rgba(16, 142, 233, .9) solid;
            color: #108EE9;
        }

        .sort-content .sort-cont .order .order-content .order-one {
            display: none;
        }

        .sort-content .sort-cont .order .order-content .order-one:nth-of-type(1) {
            display: block;
        }

        .sort-content .sort-cont .order .order-content .order-one ol li {
            display: inline-block;
            margin: 0 10px;
        }

        .sort-content .sort-cont .order .order-content .order-one ol li input {
            border-radius: 5px;
            border: none;
            border: 1px #ccc solid;
        }

        .sort-content .sort-cont .order .order-content .order-one ol li select {
            width: 80px;
            height: 24px;
            border-radius: 5px;
            border: none;
            border: 1px #ccc solid;
            font-size: 10px;
        }

        .sort-content .sort-cont .order .order-content .order-one button {
            background: rgba(16, 142, 233, .6);
            border: none;
            padding: 4px 10px;
            color: #fff;
            border-radius: 5px;
            font-size: 12px;
        }

        .sort-content .sort-cont .order .order-content .order-one table {
            width: 100%;
            margin-top: 14px;
        }

        .sort-content .sort-cont .order .order-content .order-one table thead tr {
            background: rgba(16, 142, 233, .7);
        }

        .sort-content .sort-cont .order .order-content .order-one table thead tr th {
            padding: 10px;
            color: #fff;
            text-align: center;
        }

        .sort-content .sort-cont .order .order-content .order-one table tbody tr td {
            padding: 10px;
            text-align: center;
            border: 1px #eee solid;
        }

        .sort-content .sort-cont .order .order-content .order-one table tbody tr td input {
            border-radius: 5px;
            border: none;
            border: 1px #ccc solid;
            font-size: 10px;
        }

        .sort-content .sort-cont .order .order-content .order-one table tbody tr td select {
            width: 100px;
            height: 24px;
            border-radius: 5px;
            border: none;
            border: 1px #ccc solid;
            font-size: 10px;
        }

        .sort-content .sort-cont .order .order-content .order-one table tbody tr td span {
            margin: 0 5px;
            color: #777;
            position: relative;
            cursor: pointer;
        }

        .sort-content .sort-cont .order .order-content .order-one table tbody tr td span b {
            width: 40px;
            line-height: 24px;
            background: #fff;
            position: absolute;
            bottom: -28px;
            left: -15px;
            font-weight: normal;
            font-size: 10px;
            color: #000;
            border: 1px #ccc solid;
            border-radius: 5px;
            display: none;
        }

        .sort-content .sort-cont .order-btn {
            height: 40px;
        }

        .sort-content .sort-cont .order-btn .order-btn-cont {
            float: right;
            margin-top: 10px;
        }

        .sort-content .sort-cont .order-btn .order-btn-cont button {
            padding: 2px 10px;
            border: none;
            background: rgba(16, 142, 233, .6);
            color: #fff;
            border-radius: 5px;
            color: #fff;
            margin-right: 10px;
            font-size: 12px;
        }

        .sort-content .sort-cont .order-btn .order-btn-cont button:hover {
            background: #1ab394;
        }

        .sort-content .sort-cont .order-btn .order-btn-cont button:nth-of-type(1) {
            background: #fff;
            color: #888;
            border: 1px #ccc solid;
        }
    </style>
</head>

<body><?php include_once TPL_PATH . 'public/nav.phtml'; ?>
<div class="sort-content">
    <div class="sort-title">新增课次</div>
    <form id="saveForm">
        <div class="sort-cont">
            <div class="classTime-student">
                <ul>
                    <li>学员：<?php xcho($data['student_name']) ?></li>
                    <li>课程：<?php xcho($data['course_name']) ?></li>
                    <li>订单ID：<span><?php xcho($data['order_id']) ?></span></li>
                </ul>
            </div>
            <div class="order">
                <div class="order-content">
                    <div class="order-one">
                        <ol>
                            <input type="hidden" id="student_id" name="student_id"
                                   value="<?php xcho($data['student_id']) ?>">
                            <input type="hidden" id="course_id" name="course_id"
                                   value="<?php xcho($data['course_id']) ?>">
                            <input type="hidden" id="order_id" name="order_id" value="<?php xcho($data['order_id']) ?>">
                            <input type="hidden" id="instance_id" name="instance_id"
                                   value="<?php xcho($data['instance_id']) ?>">
                            <input type="hidden" id="ctype" name="ctype" value="<?php xcho($data['ctype']) ?>">
                            <input type="hidden" id="teacher_id" name="teacher_id" value="">
                            <li>选择教师：<input type="text" id="teacher_name" name="teacher_name"
                                            url="<?php xcho($sSearchTeacher) ?>"></li>
                            <li>
                                课程状态
                                <select name="make_up_status" id="make_up_status">
                                    <?php foreach ($aLessonStatus as $aTmps) { ?>
                                        <option value="<?php xcho($aTmps['dict_value']) ?>"
                                            <?php if ($aTmps['dict_value'] == $data['make_up_status']) { ?>
                                            selected="selected"
                                        <?php } ?>><?php xcho($aTmps['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                            </li>
                        </ol>
                        <table>
                            <thead>
                            <tr>
                                <th>时间</th>
                                <th>时间段</th>
                                <th>开始时间</th>
                                <th>结束时间</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td>
                                    <input type="date" id="start_date" name="start_date" value="<?php xcho(date('Y-m-d',time())) ?>">
                                </td>
                                <td>
                                    <select name="normal_time" id="normal_time">
                                        <?php foreach ($aTimes as $aTmps) { ?>
                                            <option value="<?php xcho($aTmps['dict_value']) ?>">
                                                <?php xcho($aTmps['cn_name']) ?></option>
                                        <?php } ?>
                                    </select>
                                </td>
                                <td>
                                    <select name="start_hour" id="start_hour">
                                        <?php foreach ($aHours as $aTmps) { ?>
                                            <option value="<?php xcho($aTmps['dict_value']) ?>"
                                                <?php if (isset($aTimes[0]['dict_value']) && $aTmps['dict_value'] == substr($aTimes[0]['dict_value'],0,2))  { ?>
                                                    selected="selected"
                                                <?php } ?>>
                                                <?php xcho($aTmps['cn_name']) ?></option>
                                        <?php } ?>
                                    </select> 时
                                    <select name="start_minute" id="start_minute">
                                        <?php foreach ($aMinutes as $aTmps) { ?>
                                            <option value="<?php xcho($aTmps['dict_value']) ?>"
                                                <?php if (isset($aTimes[0]['dict_value']) && $aTmps['dict_value'] == substr($aTimes[0]['dict_value'],3,2))  { ?>
                                                    selected="selected"
                                                <?php } ?>>
                                                <?php xcho($aTmps['cn_name']) ?></option>
                                        <?php } ?>
                                    </select> 分
                                </td>
                                <td>
                                    <select name="end_hour" id="end_hour">
                                        <?php foreach ($aHours as $aTmps) { ?>
                                            <option value="<?php xcho($aTmps['dict_value']) ?>"
                                                <?php if (isset($aTimes[0]['dict_value']) && $aTmps['dict_value'] == substr($aTimes[0]['dict_value'],6,2))  { ?>
                                                    selected="selected"
                                                <?php } ?>>
                                                <?php xcho($aTmps['cn_name']) ?></option>
                                        <?php } ?>
                                    </select> 时
                                    <select name="end_minute" id="end_minute">
                                        <?php foreach ($aMinutes as $aTmps) { ?>
                                            <option value="<?php xcho($aTmps['dict_value']) ?>"
                                                <?php if (isset($aTimes[0]['dict_value']) && $aTmps['dict_value'] == substr($aTimes[0]['dict_value'],9,2))  { ?>
                                                    selected="selected"
                                                <?php } ?>>
                                                <?php xcho($aTmps['cn_name']) ?></option>
                                        <?php } ?>
                                    </select> 分
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="order-btn">
                <div class="order-btn-cont">
                    <span id="cancel" class="layui-btn layui-btn-primary">取消</span>
                    <span id="submit" class="layui-btn layui-btn-normal">确定</span>
                </div>
            </div>
        </div>
    </form>
    <input type="hidden" id="ajaxUrl" name="ajaxUrl" value="<?php xcho($ajaxUrl); ?>">
</div>
<script src="<?php xcho(loadSource('/assets/plugins/jquery/jquery.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/layui/layui.all.js')) ?>" charset="utf-8"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/jquery.dataTables.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/dataTables.bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/layer-v3.0.3/layer/layer.js')) ?>"></script>
<script
        src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/dataTables.responsive.min.js')) ?>"></script>
<script
        src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/responsive.bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/ztree/js/jquery.ztree.core.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets/plugins/ztree/js/jquery.ztree.excheck.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets/plugins/ztree/js/jquery.ztree.exedit.js')) ?>"></script>
<script>
    $(function () {
        $(".order>ul>li").click(function () {
            var ind = $(this).index();
            $(this).addClass("active").siblings("li").removeClass("active");
            $(".order>.order-content>div").eq(ind).slideDown(200).siblings("div").slideUp(200);
        })

        $("#normal_time").on('change', function () {
            var sTimes = $(this).val();
            $("#start_hour").val(sTimes.substr(0, 2));
            $("#start_minute").val(sTimes.substr(3, 2));
            $("#end_hour").val(sTimes.substr(6, 2));
            $("#end_minute").val(sTimes.substr(9, 2));
        })

        $("#teacher_name").focus(function () {
            var index = layer.open({
                type: 2
                , title: false //不显示标题栏
                , closeBtn: false
                , area: 'auto'
                , shade: 0.8
                , id: 'LAY_layuipro' //设定一个id，防止重复弹出
                , btn: ['确定', '取消']
                , moveType: 1 //拖拽模式，0或者1
                , content: $(this).attr('url')+'?date='+$("#start_date").val()+'&times='+$("#normal_time").val()
            });
            layer.full(index);
        });
        $("#submit").click(function () {
            $(".hidden_area").remove();
            var addUrl = $("#ajaxUrl").val();
            var data = {
                student_id: $("#student_id").val(),
                course_id: $("#course_id").val(),
                order_id: $("#order_id").val(),
                instance_id: $("#instance_id").val(),
                ctype: $("#ctype").val(),
                teacher_id: $("#teacher_id").val(),
                make_up_status: $("#make_up_status").val(),
                start_date: $("#start_date").val(),
                start_hour: $("#start_hour").val(),
                start_minute: $("#start_minute").val(),
                end_hour: $("#end_hour").val(),
                end_minute: $("#end_minute").val(),
            };
            $.ajax({
                url: addUrl,
                data: data,
                type: 'POST',
                dataType: 'json',
                success: function (data) {
                    if(data.success==1){
                        $("#cancel").trigger("click");
                    }else{
                        $.each(data.errors,function (sKey,aVal) {
                            $('#'+sKey).after("<span class='hidden_area' style='color: red;padding-top: 5px;'>"+aVal['message']+"</span>");
                        })
                    }
                }
            })
        })
        //关闭添加课次
        $("#cancel").on("click", function () {
            window.history.back();
        })
    });

</script>
<?php include_once TPL_PATH . 'public/foot_script.phtml'; ?>
<button id="top" style="height: 50px;width: 50px;"></button></body>

</html>
